package com.example.service;

import com.example.mapper.BookMapper;
import com.example.pojo.Book;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BookServiceImpl implements BookService {

    @Autowired
    private BookMapper bookMapper;

    // 查询所有图书数据
    @Override
    public List<Book> getAllBooks() {
        return bookMapper.getAllBooks();
    }

    // 修改图书价格（传入ID和新价格）
    @Override
    public boolean updatePrice(int id, double newPrice) {
        return bookMapper.updateBookPrice(id, newPrice) > 0;
    }

    // 修改图书状态（传入ID和新状态码）
    @Override
    public boolean updateStatus(int id, int newStatus) {
        return bookMapper.updateBookStatus(id, newStatus) > 0;
    }
}